#coding:utf-8

import datetime
import random
import time

#模拟产生log
#产生50个id，整10的id没有request end，其他的随机产生结束时间


fp=open("some_log",'wb')
num=1
have_begin=[]
while num<=50:
    is_end = random.choice((0,1))
    if have_begin and is_end:
        end_num=random.choice(have_begin)
        if end_num%10:
            fp.write("#%d 0.0.0.0 [%s] request end: OK\r\n"%(end_num,time.strftime("%Y-%m-%d %H:%M:%S")))
        have_begin.remove(end_num)
    else:
        fp.write("#%d 0.0.0.0 [%s] request begin: OK\r\n"%(num,time.strftime("%Y-%m-%d %H:%M:%S")))
        num+=1
        have_begin.append(num)
        time.sleep(random.randrange(1,10))

fp.close()
